home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / DLFCN.ZIP / dlfcn / octave / safe-lstat.h < prev    next >
C/C++ Source or Header  |  1997-08-20  |  2KB  |  79 lines

  1. /* safe-lstat.h -- EINTR-safe interface to lstat
  2.    Copyright (C) 1994 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.    
  18. /* Written by Jim Meyering <meyering@comco.com>.  */
  19.  
  20. #ifndef _safe_lstat_h_
  21. #define _safe_lstat_h_ 1
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27. /* NOTE: you must include the following headers (in the listed order)
  28.    before this one: <sys/types.h>, <sys/stat.h>.  */
  29.  
  30. #if !defined(S_ISLNK) && defined(S_IFLNK)
  31. #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  32. #endif
  33.  
  34. #ifndef S_ISLNK
  35. #include "safe-stat.h"
  36. #define SAFE_LSTAT SAFE_STAT
  37. #define safe_lstat safe_stat
  38. #else
  39.  
  40. #include <errno.h>
  41.  
  42. #ifndef errno
  43. extern int errno;
  44. #endif
  45.  
  46. #ifndef __GNUC__
  47. #define __inline /* empty */
  48. #endif
  49.  
  50. /* On some systems, lstat can return EINTR.  */
  51.  
  52. #ifndef EINTR
  53. # define SAFE_LSTAT(name, buf) lstat (name, buf)
  54. #else
  55. # ifndef __static
  56. #   define __static static
  57. # endif
  58. # define SAFE_LSTAT(name, buf) safe_lstat (name, buf)
  59. __static __inline int
  60. safe_lstat (const char *name, struct stat *buf)
  61. {
  62.   int ret;
  63.  
  64.   do
  65.     ret = lstat (name, buf);
  66.   while (ret < 0 && errno == EINTR);
  67.  
  68.   return ret;
  69. }
  70. #endif
  71.  
  72. #endif /* S_ISLNK */
  73.  
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77.  
  78. #endif /* _safe_lstat_h_ */
  79.